package com.kavian.common.util;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

/**  
 * Description:   
 * Copyright:   Copyright (c)2012 
 * Company:     qoocc 
 * @author:    	kavian
 * @version:    1.0  
 * Create at:  2012-4-21下午04:41:06
 *  
 * Modification History:  
 * Date                      Author           Version     Description  
 * ------------------------------------------------------------------  
 * 2012-4-21下午04:41:06   	     Administrator          1.0        1.0 Version  
 */
public class PropertiesUtil {

	private static String FILE_NAME = "/properties/tomcat.properties";

	private static Properties properties;

	static {
		properties = getProperties(FILE_NAME);
	}

	private PropertiesUtil() {
	}

	/**
	 * 获取Properties
	 * 
	 * @return
	 */
	public static Properties getProperties() {
		return properties;
	}

	public static Properties getProperties(String fileName) {
		Properties result = new Properties();
		try {
			result.load(PropertiesUtil.class.getResourceAsStream(fileName));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * 获取字符串类型的属性
	 * 
	 * @param name
	 *            属性名
	 * @return
	 */
	public static String getProperty(String name) {
		return properties.getProperty(name);
	}

	public static void initEnvironment() {
		properties = getProperties(FILE_NAME);
	}
	
	public static void main(String[] args) {
		System.out.println(getProperty("start_tomcat_file"));
	}

}
